/*
 * @Author: _LJP 2634716776@qq.com
 * @Date: 2024-01-03 14:51:12
 * @LastEditors: _LJP 2634716776@qq.com
 * @LastEditTime: 2024-01-06 16:13:18
 * @FilePath: /my_-linux/Pro24/Tree/RBT/RBTree/test.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>



#include"RBTree.hpp"

#include"AVLTree.hpp"



using namespace std;

void test1()
{

  
  RBTree<int, int> rb1;
    rb1.Insert(make_pair(1,1));
    rb1.Insert(make_pair(2,2));
    rb1.Insert(make_pair(3,3));
    rb1.Insert(make_pair(4,4));
}
void test2()
{
    RBTree<int, int> rb1;
    int a[] = {16, 3, 7, 11, 9, 26, 18, 14, 15};

    for (auto e : a)
    {
        rb1.Insert({e, e});
    }
    rb1.InOrder();

    cout << rb1.IsBalance() << endl;
}
void test3()
{
    RBTree<int, int> rb1;

    int a[] = {4, 2, 6, 1, 3, 5, 15, 7, 16, 14};
    // int a[] = {4, 2, 6, 1, 3, 5, 15, 7, 16, 14, 12, 14, 54, 23, 21, 56, 57, 45, 32};
    // int a[] = {4, 2, 6, 1 /*  ,3,5,15,7,16,14,12,14,54,23,21,56,57,45,32*/};

    for (auto e : a)
    {
        rb1.Insert({e, e});
    }
    rb1.InOrder();

    cout << rb1.IsBalance() << endl;
}

void test4()
{
    srand(time(0));
    const size_t N = 7500000;
    RBTree<int, int> rb1;
    AVLTree<int,int> avl1;
    for (size_t i = 0; i < N; ++i)
    {
        size_t x = rand()+i;
        rb1.Insert(make_pair(x, x));
        avl1.Insert(make_pair(x,x));
    }

    // cout<<rb1.IsBalance()<<endl;

    cout << rb1.getHeight() << endl;
    cout << avl1.getHeight() << endl;
}

int main()
{
    // test1();

    // cout << "--------------------" << endl;

    // test2();

    cout << "--------------------" << endl;

    // test3();
    // cout << "--------------------" << endl;
    test4();

    return 0;
}
// int main()
// {
//     // cout<<"hello world"<<endl;
//     test1();
//     return 0;
// }
